#include <stdio.h>
#include <stdlib.h>

typedef struct Linked_Lists
{
	int a;
	struct Linked_Lists * next;
} Linked_List;

Linked_List * Iter_Linked_List(void)
{
	// Linked_List * head = NULL;
	Linked_List * Linked_List_pointer = (Linked_List *)malloc(sizeof(Linked_List));
	Linked_List * head = Linked_List_pointer;
	for (int i = 0; i < 5; i++)
	{
		Linked_List * node = (Linked_List *)malloc(sizeof(Linked_List));
		// temp->next = NULL;
		node->a=i;
		Linked_List_pointer->next = node;
		Linked_List_pointer = Linked_List_pointer->next;
	}
	return Linked_List_pointer;
}

Linked_List * Create_Linked_List(void)
{
	/*
	其成型方法类似于DNA的复制，现定义一个启动子，再在for循环中定义链表节点，
	将节点赋在启动子上，最后抛弃节点，将启动子返回。
	之后可以遍历启动子，找到启动子上的所有地址的值。
	*/
	// Linked_List * head = NULL;
	Linked_List * Linked_List_pointer = (Linked_List *)malloc(sizeof(Linked_List));
	Linked_List * head = Linked_List_pointer;
	for (int i = 1; i < 6; i++)
	{
		Linked_List * node = (Linked_List *)malloc(sizeof(Linked_List));
		// temp->next = NULL;
		node->a=i;
		Linked_List_pointer->next = node;
		Linked_List_pointer = Linked_List_pointer->next;
	}
	// printf("Created!\n");
	return head;
}

void Delete_Element_From_Linked_List(Linked_List * head, int DelI)
{
	/*for(int i=0; i < DelI; i++)
	//{
		if(head->next == NULL)
		{
			head=head->next;
		}
	}*/
	printf("%p\n", head);
}

// 测试用例`[1,2,3,4,5]`
/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */
struct Linked_Lists * middleNode(struct Linked_Lists * head){
    int val = 0;
	head=head->next;
	printf("个数是%p", head);
	while(head)
	{
		printf("%d\n", head->a);
		head=head->next;
		val++;
	}
	if(0 == val % 2)
	{
		val = val /2;
	}
	else
	{
		val = val / 2 + 1;
	}
    // middleNode(arr);
	Delete_Element_From_Linked_List(head, val);
}

int main(void)
{
	Linked_List * head = Create_Linked_List();
    // int arr[] = {1,2,3,4,5};
	Linked_List * res = middleNode(head);
    // middleNode(arr);

	printf("\n");
	return 0;
}
